#include "StdAfx.h"
#include "Image.h"

Image::Image(const int width, const int height)
{
	m_width = width;
	m_height = height;
	pixels = new int[width*height];
}

Image::Image( void )
:m_width(0),
 m_height(0)
{
}

Image::~Image(void)
{
	delete[] pixels;
}

void Image::setRGB( const int x, const int y, const int rgb ) {
	pixels[x + y * m_width] = rgb;
}

int Image::getRGB( const int x, const int y ) const {
	return pixels[x + y * m_width];
}

int Image::getWidth( void ) const {
	return m_width;
}

void Image::setWidth( const int width )
{
	m_width = width;
	if( m_height != 0 )
		pixels = new int[ m_height * m_width ];
}

int Image::getHeight( void ) const {
	return m_height;
}

void Image::setHeight( const int height )
{
	m_height = height;
	if( m_width != 0 )
		pixels = new int[ m_height * m_width ];
}

int* Image::getPixels( void ) {
	return pixels;
}